package org.lhh.server.common.utils;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.Properties;

public class PropertiesUtil {

    private static Properties prop;

    public static void init() throws IOException {
        if (prop == null) {
            prop = new Properties();
            InputStream resourceAsStream = PropertiesUtil.class.getClassLoader().getResourceAsStream("params.properties");
            if (resourceAsStream != null)
                prop.load(new InputStreamReader(resourceAsStream, StandardCharsets.UTF_8));
        }
    }

    public static String getString(String key) {
        return prop.getProperty(key);
    }

    public static Integer getInteger(String key) {
        return Integer.valueOf(prop.getProperty(key));
    }

    public static Double getDouble(String key) {
        return Double.valueOf(prop.getProperty(key));
    }
}



